/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.item.etcitem.action;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.item.ItemExecutor;
import com.lineage.server.model.item.SkillEffectGfx;
import com.lineage.server.packetserver.S_OwnCharStatus;
import com.lineage.server.packetserver.S_ServerMessage;

/**
 * Class <code>PotionBackRaw</code> 返生药水 - 43000.
 * 
 * @author jrwz
 * @version 2012-6-24上午06:31:39
 * @see com.lineage.server.model.item.etcitem.action
 * @since JDK1.7
 */
public final class PotionBackRaw extends ItemExecutor {

    /** 提示信息. */
    private static final Logger LOG = Logger.getLogger(PotionBackRaw.class
            .getName());

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static ItemExecutor get() {
        return new PotionBackRaw();
    }

    /** 返生药水 - 43000. */
    private PotionBackRaw() {
    }

    @Override
    public void execute(final L1PcInstance pc, final L1ItemInstance useItem,
            final int readC1, final int readC2, final int targetId,
            final int targetX, final int targetY) {
        try {
            pc.setExp(1); // 总经验值归1
            pc.resetLevel(); // 等级重算
            pc.setBonusStats(0); // 清空奖励属性点记录 (升级可以继续点奖励属性点)
            pc.getInventory().takeoffEquip(945); // 用来脱掉全身装备
            pc.sendPackets(new S_OwnCharStatus(pc)); // 更新角色属性与能力值
            pc.sendPackets(new S_ServerMessage(822)); // 你感受到体内深处产生一股不明力量。
            SkillEffectGfx.get().execute(pc, 2568, (byte) 2); // 风龙降临动画特效。
            pc.save(); // 将玩家资料储存到资料库中
        } catch (final Exception e) {
            LOG.log(Level.SEVERE, e.getLocalizedMessage(), e);
            throw new Error("返生药水错误.");
        }
        pc.checkNoviceType(); // 处理新手保护系统(遭遇的守护)状态资料的变动
        pc.getInventory().removeItem(useItem, 1); // 删除道具
    }
}
